package com.example.arch;

import android.arch.lifecycle.LiveData;
import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.ViewModel;
import android.util.Log;
import com.example.arch.bean.User;

/**
 * Created by zhangwei on 2017/6/26.
 */
public class UserViewModel extends ViewModel {
    private MutableLiveData<User> liveUser;

    public UserViewModel() {
        liveUser = new MutableLiveData<>();
        User user = new User();
        user.name = "111";
        liveUser.setValue(user);
    }

    public LiveData<User> getUser() {
        return liveUser;
    }

    public void setLiveUser(User user) {
        liveUser.setValue(user);
        Log.e("s", "sdf:"+liveUser.getValue().name);
    }
}
